package com.walker.controller.catalogue;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.walker.anno.ResponseResult;
import com.walker.service.catalogue.CatalogueDerivateIndexService;

import net.sf.json.JSONObject;

/**
 * 资产-目录-指标
 */
@RestController
@RequestMapping(value = "/catalogueDerivateIndex")
@ResponseResult
public class CatalogueDerivateIndexController {

	@Resource
	private CatalogueDerivateIndexService service;
	
	/**
	 * 指标列表
	 * @param request
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@PostMapping("queryDeriveList")
	public Map<String, Object> queryDeriveList(@RequestBody String request) {
		Map<String, Object> params = JSONObject.fromObject(request);
		return service.queryDeriveList(params);
	}
	
	/**
	 * 项目信息
	 * @return
	 */
	@PostMapping("queryProjectInfo")
	public List<Map<String, Object>> queryProjectInfo() {
		return service.queryProjectInfo();
	}
	
	/**
	 * 维度表信息
	 * @param project_id
	 * @return
	 */
	@PostMapping("queryDimInfo")
	public List<Map<String, Object>> queryDimInfo(@RequestBody(required = false) String project_id) {
		return service.queryDimInfo(project_id);
	}
	
	/**
	 * 事实逻辑表信息
	 * @param project_id
	 * @return
	 */
	@PostMapping("queryFactLogicInfo")
	public List<Map<String, Object>> queryFactLogicInfo(@RequestBody(required = false) String project_id) {
		return service.queryFactLogicInfo(project_id);
	}
	
	/**
	 * 汇总表逻辑表信息
	 * @param project_id
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@PostMapping("querySumLogicInfo")
	public List<Map<String, Object>> querySumLogicInfo(@RequestBody(required = false) String request) {
		Map<String, Object> params = new HashMap<String,Object>();
		if(StringUtils.isNotBlank(request)){
			params = JSONObject.fromObject(request);
		}
		return service.querySumLogicInfo(params);
	}
	
	/**
	 * 原子指标信息
	 * @param project_id
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@PostMapping("queryAtomicInfo")
	public List<Map<String, Object>> queryAtomicInfo(@RequestBody(required = false) String request) {
		Map<String, Object> params = new HashMap<String,Object>();
		if(StringUtils.isNotBlank(request)){
			params = JSONObject.fromObject(request);
		}
		return service.queryAtomicInfo(params);
	}
	
	/**
	 * 产出信息
	 * @param request
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@PostMapping("queryTaskList")
	public Map<String, Object> queryTaskList(@RequestBody String request) {
		Map<String, Object> params = JSONObject.fromObject(request);
		return service.queryTaskList(params);
	}
}